namespace YM {
    export class game {
        static scene: Scene = null;
        private static _event: EventSystem;
        static get event() {
            if (this._event == null) {
                this._event = new EventSystem();
            }
            return this._event;
        }

        private static _objectPool: ObjectPool;
        public static get objectPool(): ObjectPool {
            if (this._objectPool == null) {
                this._objectPool = new ObjectPool();
            }
            return this._objectPool;
        }
        
        private static _ui:UIMgr;
        public static get ui(){
            if(this._ui==null){
                this._ui=new UIMgr();
            }
            return this._ui;
        }
        private static _config:ConfigMgr;
        public static get config():ConfigMgr{
            if(this._config==null){
                this._config=new ConfigMgr();
            }
            return this._config;
        }
        private static _res:Resource;
        public static get res(){
            if(this._res==null){
                this._res=new Resource();
            }
            return this._res;
        }
        private static _audio:AudioMgr;
        public static get audio():AudioMgr{
            if(this._audio==null){
                this._audio=new AudioMgr();
            }
            return this._audio;
        }
        private static _pool:NodePool;
        public static get pool():NodePool{
            if(this._pool==null){
                this._pool=new NodePool();
            }
            return this._pool;
        }
        public static close(): void {
            if (this.scene != null)
                this.scene.dispose();
            this.scene = null;

            if (this._objectPool != null)
                this._objectPool.dispose();
            this._objectPool = null;

            this._event = null;
        }
    }
}